//
//  XJLSendRedPacketViewController.m
//  XJL_WeChat
//
//  Created by XJL on 16/8/25.
//  Copyright © 2016年 Xujiali. All rights reserved.
//

#import "XJLSendRedPacketViewController.h"

@interface XJLSendRedPacketViewController ()
@property (weak, nonatomic) IBOutlet UITextField *amounField;

@end

@implementation XJLSendRedPacketViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"取消" style:0 target:self action:@selector(cancel)];
}

-(void)cancel{
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}
- (IBAction)sendRedPacketAction:(UIButton *)sender {
    //1.发送个网络请求给自己的服务器
    [SVProgressHUD showSuccessWithStatus:@"发送中。。。"];
    
    //模拟网络请求
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
       
        if (self.didSendRedPacket) {
            self.didSendRedPacket([self.amounField.text doubleValue],1);
        }
        [SVProgressHUD dismiss];
        [self dismissViewControllerAnimated:YES completion:nil];
    });
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
